﻿CREATE PROCEDURE [dbo].[yaf_userforum_save](
                @UserID       INT,
                @ForumID      INT,
                @AccessMaskID INT)
AS
    BEGIN
        IF EXISTS (SELECT 1
                   FROM   yaf_UserForum
                   WHERE  UserID = @UserID
                   AND ForumID = @ForumID)
        UPDATE yaf_UserForum
        SET    AccessMaskID = @AccessMaskID
        WHERE  UserID = @UserID
        AND ForumID = @ForumID
        ELSE
        INSERT INTO yaf_UserForum
                   (UserID,
                    ForumID,
                    AccessMaskID,
                    Invited,
                    Accepted)
        VALUES     (@UserID,
                    @ForumID,
                    @AccessMaskID,
                    Getdate(),
                    1)
    END


